module.exports = {
    start: false,
    game_over: false,
    over_lab: cc.Node,
    score: cc.Node,
    bird: cc.Node,
    pipe1: null,
    pipe2: null,
    root: null,
    pipe1_pool: cc.Prefab,
    pipe2_pool: cc.Prefab,
    pipe_exist: 0,
    pipe_count: 10,
    pipe1_arr: [],
    pipe2_arr: [],
    createPipe() {
        console.log(this.pipe1_pool);
        if (!this.game_over) {
            console.log('创建油管');
            this.pipe_exist++;
            var pipe1 = null;
            var pipe2 = null;
            if (this.pipe1_pool.size() > 0) {
                pipe1 = this.pipe1_pool.get();
                console.log('获取p1');
            } else {
                pipe1 = cc.instantiate(this.pipe1);
                this.pipe1_arr.push(pipe1);
            }
            if (this.pipe2_pool.size() > 0) {
                pipe2 = this.pipe2_pool.get();
                console.log('获取p2');
            } else {
                pipe2 = cc.instantiate(this.pipe2);
                this.pipe2_arr.push(pipe2);
            }
            console.log(pipe1)
            var y = parseInt(Math.random() * (500 - 110 + 1) + 110, 10);
            var x = 880;
            pipe1.position = cc.v2(x, -y);
            pipe2.position = cc.v2(x, 610 - y);
            pipe1.parent = this.root;
            pipe2.parent = this.root;
            pipe1.getComponent('pipe1').init();
            pipe2.getComponent('pipe2').init();
        }
    },
    getOnePoint() {
        this.score.string++;
    },
    clearPipe() {
        for (let i = 0; i < this.pipe1_arr.length; i++) {
            this.pipe1_arr[i].destroy();
            this.pipe2_arr[i].destroy();
        }
        this.pipe1_arr = [];
        this.pipe2_arr = [];
    }
};
